package cn.mjnxin.charge.service.base;

import java.io.Serializable;
import java.util.List;

import cn.mjnxin.charge.mybatis.mapper.base.BaseMapper;

public abstract class BaseRepository<D, E, PK extends Serializable> {
    public long countByExample(E example){
        return getMapper().countByExample(example);
    }

    public int deleteByExample(E example){
        return getMapper().deleteByExample(example);
    }

    public int deleteByPrimaryKey(PK id){
        return getMapper().deleteByPrimaryKey(id);
    }

    public int insert(D domain){
        return getMapper().insert(domain);
    }

    public int insertSelective(D domain){
        return getMapper().insertSelective(domain);
    }

    public List<D> selectByExample(E example){
        return getMapper().selectByExample(example);
    }

    public D selectByPrimaryKey(PK id){
        D obj = getMapper().selectByPrimaryKey(id);
        if(obj==null)return null;
        return obj;
    }
    public int updateByExampleSelective(D domain,  E example){
        return getMapper().updateByExampleSelective(domain,example);
    }

    public int updateByExample(D domain, E example){
        return getMapper().updateByExample(domain,example);
    }

    public int updateByPrimaryKeySelective(D record){
        return getMapper().updateByPrimaryKeySelective(record);
    }

    public int updateByPrimaryKey(D record){
        return getMapper().updateByPrimaryKey(record);
    }

    public abstract BaseMapper<D, E, PK> getMapper();
}
